<template>
	<view>
		<u-picker :show="show" @confirm="confirm" :columns="columns" keyName="label"></u-picker>
		<view class="addForm">
			<view class="formBox">
				<u--form :model="FormData" ref="FormData" :rules="rules" labelWidth=100>
					<u-form-item label="姓名" prop="name" borderBottom>
						<u-input v-model="FormData.name" border="none" placeholder="请填写姓名" inputAlign="right"></u-input>
					</u-form-item>
					<u-form-item label="手机号码" prop="phoneNumber" borderBottom>
						<u-input v-model="FormData.phoneNumber" border="none" placeholder="请填写手机号" inputAlign="right" type="number"></u-input>
					</u-form-item>
					<u-form-item @click="btnGx" label="省市区" prop="district" borderBottom>
						<u-input v-model="FormData.district" border="none" placeholder="请选择" inputAlign="right" readonly></u-input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="详细地址" prop="address" borderBottom>
						<u-input v-model="FormData.address" border="none" placeholder="请填写详细地址" inputAlign="right"></u-input>
					</u-form-item>
				</u--form>
			</view>
		</view>
		<view class="addfoot">
			<view class="addBtn" @click="submit">保存</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				columns: [
					[   
						{
							label: '湖南省',
							id: 1
						},
						{
							label: '湖北省',
							id: 2
						},
					]
				],
				FormData:{
					name:'',
					
				},
				rules: {
					name: [{
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					}],
					phoneNumber: [{
						type: 'string',
						required: true,
						message: '请填写手机号码',
						trigger: ['blur', 'change']
					}],
					district: [{
						type: 'string',
						required: true,
						message: '请选择省市区',
						trigger: ['blur', 'change']
					}],
					address: [{
						type: 'string',
						required: true,
						message: '请填写详细地址',
						trigger: ['blur', 'change']
					}],
				}
			}
		},
		methods: {
			submit() {
				this.$refs.FormData.validate().then(res => {
					uni.$u.toast('校验通过')
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})
			},
			btnGx() {
				this.show = true;
			},
			confirm(e){
				this.FormData.district = e.value[0].label;
				this.show = false;
			}
		}
	}
</script>

<style lang="scss">
	body {
		background-color: $uni-bg-color-grey;
	}
	.addForm {
		padding: 20rpx;
	}
	.formBox {
		background: #ffffff;
		border-radius: 10rpx;
		overflow: hidden;
		margin-bottom: 20rpx;
		box-shadow: 3rpx 3rpx 6rpx 0 #D3D0D0;
		padding: 0 20rpx;
	}
	.u-form-item__body__right__message.data-v-067e4733 {
		text-align: right;
	}
	.addfoot {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 140rpx;
		box-shadow: 0 -5rpx 10rpx #D3D0D0;
	}
	
	.addBtn {
		width: 90%;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		background: linear-gradient(to left, $uni-aicloud, $uni-aicloud-gradation);
		color: #ffffff;
		font-size: 28rpx;
		border-radius: 80rpx;
		margin: 30rpx auto;
	
	}
</style>